package com.waitingresult.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-10-20  19:40
 * @Description:
 * @Version: 1.0
 */
@Configuration
public class MqConfig {
    public static final String FANOUT_EXCHANGE_DEMO = "fanout-exchange-demo";
    public static final String QUEUE1 = "fanout-exchange-demo-queue1";
    public static final String QUEUE2 = "fanout-exchange-demo-queue2";
    public static final String ROUTING_KEY = "";
    @Bean
    public Exchange fanoutExchange(){
        //点对点
        //return ExchangeBuilder.directExchange(FANOUT_EXCHANGE_DEMO).build();
        return ExchangeBuilder.fanoutExchange(FANOUT_EXCHANGE_DEMO).build();
    }

    @Bean
    public Queue queue1(){
        return QueueBuilder.durable(QUEUE1).build();
    }
    @Bean
    public Queue queue2(){
        return QueueBuilder.durable(QUEUE2).build();
    }

    @Bean
    public Binding fanoutBinding1(Exchange fanoutExchange, Queue queue1){
        return BindingBuilder.bind(queue1).to(fanoutExchange).with(ROUTING_KEY).noargs();
    }
//    @Bean
//    public Binding fanoutBinding2(Exchange fanoutExchange,Queue queue2){
//        return BindingBuilder.bind(queue2).to(fanoutExchange).with(ROUTING_KEY).noargs();
//    }

    /**        简单模式        */

}
